const arr = [66, 88, 12, 87, 100, 5, 566, 23]

const insertionSort = (arr) => {
  for (let i = 1; i < arr.length; i++) {
    let j = i
    const temp = arr[i]
    while (arr[j - 1] > temp && j > 0) {
      arr[j] = arr[j - 1]
      j--
    }
    arr[j] = temp
  }
}

insertionSort(arr)

console.log('arr', arr);
